#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int w, n;
int q[N];

int main() {
	cin >> w >> n;
	for (int i = 0; i < n; ++i) {
		cin >> q[i];
	}
	sort(q, q + n);
	int res = 0;
	int l = 0, r = n - 1;
	while (l <= r) {
		if (q[l] + q[r] <= w) {
			l++, r--, res++;
		} else {
			r--, res++;
		}
	}

	cout << res << endl;
	return 0;
}